package cn.sail.shop3.api.controller;

import cn.sail.shop3.api.entity.Goods;
import cn.sail.shop3.api.service.GoodsService;
import cn.sail.shop3.api.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/goodsId")
public class GoodsIdServlet extends BaseServlet {

    private GoodsService goodsService = new GoodsServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("goodsIdServlet");
        String id1 = req.getParameter("arg");
        System.out.println(id1);
        Long id = Long.parseLong(id1);
        System.out.println(id);
//        String id3 = req.getParameter("id2");
//        int id = Integer.parseInt(id3);
        System.out.println("dbGoodsId2");

        //获取单个商品的数据
        Goods dbGoodsId = goodsService.goodsById(id);
        System.out.println(dbGoodsId);
        //业务成功返回
        successResp(resp, dbGoodsId);

        System.out.println("dbGoodsId");
    }

}
